import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * user:likai
 * Date:2022-12-07
 * Time:14:48
 */
//懒汉
class Singletonlazy{
    private static Singletonlazy instance=null;
    //禁用，不能直接new对象
    private Singletonlazy (){
    }
    private static Singletonlazy getInstance(){
        if(instance==null){
            synchronized (Singletonlazy.class){
                if(instance==null){
                    instance=new Singletonlazy();
                }
            }
        }
        return instance;
    }
}
//饿汉
class Singleton{
    private static Singleton instance=new Singleton();
    private Singleton getInstance(){
        return instance;
    }
    private Singleton(){

    }
}
public class Test {
    public static void main1(String[] args) {
        Object object=new Object();
        Thread A=new Thread(()->{
           synchronized (object){
               System.out.println("A.A");
               try {
                   object.wait();
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
               System.out.println("A.B");
           }
        });
        //需要先执行完notify的代码块执行完，推出代码块，才能执行wait后的代码块
        Thread B=new Thread(()->{
            synchronized (object){
                System.out.println("B.A");
                object.notify();
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("B.B");
            }
        });
        A.start();
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        B.start();
    }
    public static void main2(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int []array=new int[n+1];
        int i=0;
        while(scanner.hasNext()){
            array[i++]=scanner.nextInt();
        }
        int sum=0;
        int j=0;
        while(j<n){
            if(j<n&&array[j]<array[j+1]){
                while(array[j]<=array[j+1]){
                    j++;
                }
                sum++;
                j++;
            } else if (j<n&&array[j]>array[j+1]) {
                while(array[j]>=array[j+1]){
                    j++;
                }
                sum++;
                j++;
            }else{
                j++;
            }
        }
        System.out.println(sum);
    }
}
